# -*- coding: utf-8 -*-
# @Date   : 2021/07/15
# @File   : R76_CompanyNationalityCheck_CF.py
# @Author : zhanghengfeng

'''eof
name:申请企业注册地校验
code:R76_CompanyNationalityCheck_CF
tableName:
columnName:
groups:出口信息模块
dependencies:CF_CQ_DSJ
type:常用指标
dataSourceType:
eof'''


null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']


def R75_PastYearARAndARRatioCheck_CF():
    try:
        tradeInfo = CF_CQ_DSJ['body']['tradeInfo']
        if tradeInfo in null_type_list:
            return u'缺失值'
        elif tradeInfo == []:
            return u'缺失值'
        elif isinstance(tradeInfo,list) and len(tradeInfo)>0:
            countryCode =  tradeInfo[0].get('countryCode')
            if countryCode.isalpha() and countryCode.isupper() and len(countryCode)== 3:
                if countryCode == "CHN":
                    return 1
                else:
                    return 0
            else:
                return u'缺失值'
        else:
            return u'缺失值'
    except:
            return u'缺失值'
result = R75_PastYearARAndARRatioCheck_CF()
    